<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

const line = ref()
onMounted(() => {
  let mycharts = echarts.init(line.value)
  mycharts.setOption({
    color: ['#165DFF'],
    tooltip: {
      show: false,
      trigger: 'axis',
      axisPointer: {
        // 坐标轴指示器，坐标轴触发有效
        type: 'shadow', // 默认为直线，可选为：'line' | 'shadow'
      },
    },
    grid: {
      left: '0%',
      right: '5%',
      bottom: '0%',
      top: '0%',
      containLabel: true,
    },
    xAxis: [
      {
        type: 'category',
        data: ['1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7'],
        boundaryGap: false,
        axisTick: {
          show: true, // 不显示坐标轴刻度线
        },
        splitLine: {
          show: false,
        },
        axisLine: {
          show: true,
        },
        axisLabel: {
          interval: 0,
          color: '#86909C',
          fontSize: 14,
        },
      },
    ],
    yAxis: [
      {
        type: 'value',
        show: false,
        //y右侧文字
        axisLabel: {
          color: 'rgba(230, 247, 255, 0.50)',
          fontSize: 16,
        },
        // y轴的分割线
        splitLine: {
          show: true,
          lineStyle: {
            type: 'dashed',
            color: 'rgba(230, 247, 255, 0.20)',
          },
        },
      },
    ],
    series: [
      {
        name: '',
        type: 'line',
        smooth: true,
        symbol: 'circle', // 不显示连接点
        tooltip: {
          trigger: 'axis',
        },
        lineStyle: {
          width: 2,
          shadowColor: '#165DFF',
          shadowBlur: 20,
        },
        label: {
          show: true,
          position: 'top', // 数据点值的位置
          color: 'white', // 数据点值的颜色
          fontSize: 16, // 数据点值的字体大小
          fontWeight: 'bold', // 数据点值的字体粗细
        },
        areaStyle: {
          opacity: 0.8,
          color: {
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: 'rgba(22, 93, 255, 0.5)',
              },
              {
                offset: 0.3,
                color: 'rgba(22, 93, 255, 0.2)',
              },
              {
                offset: 1,
                color: 'rgba(22, 93, 255, 0)',
              },
            ],
          },
        },
        data: [140, 232, 101, 264, 90, 340, 250],
      },
    ],
  })
})
</script>

<template>
  <div class="box5">
    <div class="title">
      <p>未来七天游客数量趋势图</p>
      <img src="../images/dataScreen-title.png" alt="" />
    </div>
    <div class="charts" ref="line"></div>
  </div>
</template>

<style scoped lang="scss">
.box5 {
  width: 100%;
  height: 100%;
  background: url(../images/dataScreen-main-cb.png) no-repeat;
  background-size: cover;
  margin: 0px 20px;

  .title {
    margin-left: 10px;

    p {
      color: white;
      font-size: 20px;
    }
  }

  .charts {
    height: calc(100% - 40px);
  }
}
</style>
